<template>
  <div class="IsData">
    <span v-if="data || data===0">
      <template v-if="type==='日期' && typeof data==='string'">
        {{data.split(' ')[0]}}
      </template>
      <template v-else-if="typeof data==='number'">
        {{data.toFixed(precision)}}
      </template>
      <template v-else>
        {{data}}
      </template>
    </span>
    <span class="placeholder" v-else>{{placeholder || '--'}}</span>
  </div>
</template>
<script>
export default {
  name: "IsData",
  props: {
    data:{},
    placeholder:{
      type:String,
    },
    type:{
      type:String,
    },
    precision:{
      type:Number,
      default: () => {
        return 0;
      },
    },
  }, // 获取父组件数据
  components: {

  },
  created() {

  },
  data() {
    return {

    };
  },
  methods: {

  },
  computed: {

  }
};
</script>
<style  lang="scss" scoped>
::v-deep.IsData{
  display: inline-flex;
  .placeholder{
    color: #c0c4cc;
  }
  & + span{
    margin-left: 4px;
  }
}
</style>
